<?php

class Default_TourController extends Zend_Controller_Action
{
  	
    public function init()
    {
        
    }
    
    public function indexAction()
    {
       
    	$country = Zend_Registry::get('countryId');
    	
    	$this->view->country = $country;
    	$db_theme = new  Default_Model_DbTable_Theme();
    	$this->view->theme = $db_theme->fetchAll();
    	 
    }
    public function listtourAction()
    {
    	
    	$countryname = $this->_getParam('country', 0);
    	$countryId = Zend_Registry::get('countryId');
    	$this->view->country = $countryId;
    	
    	////// themes and region keyword /////
    	$theme = $this->_getParam('theme',0);
    	$region = $this->_getParam('region',0);
    	
    	/////// sort keyword //////////
    	$newest = $this->_getParam('newest', 0);
    	$bestchoice =$this->_getParam('bestchoice', 0);
    	$mostpopular = $this->_getParam('mostpopular', 0);
    	
    	/////// filter keyword ////////
    	$tourtype = $this->_getParam('tourtype',0);
    	$tourtypeId=0;
    	switch ($tourtype) {
    		case 'sorttour':
    		    $tourtypeId = 1;
    		    break;
    		case 'sorttour':
    		    $tourtypeId = 2;
    		    break;
    	}
    	$regionId = $this->_getParam('regionId',0);
      	$theme = $this->_getParam('theme',0);
    	///////// page ///////////////
    	$page = $this->_getParam('page',1);
    	
    	
    	$db_tour = new  Default_Model_DbTable_Tour();
        $db_region = new  Default_Model_DbTable_Region();
        $db_theme = new  Default_Model_DbTable_Theme();
    	
        $tours = $db_tour->gettour($page, $tourtypeId, $countryId, $regionId, $theme);
        
        $this->view->tourtype = $tourtype;
       
        $this->view->countryname = $countryname;
        $this->view->region = $db_region->getregion($countryId);
        $this->view->theme = $db_theme->fetchAll();
		$this->view->tourtypeId = $tourtypeId;
		$this->view->regionId = $regionId;
		$this->view->themeId = $theme;
		$this->view->tours = $tours;
    }
    public function detailshorttourAction()
    {
        
        $countryname = $this->_getParam('countryname', 0);
        
        $countryId = Zend_Registry::get('countryId');
    	$this->view->country = $countryId;
        
        $tourId = $this->_getParam('tourId', 0);
        
        $db_tour = new  Default_Model_DbTable_Tour();
        $db_inclusion = new Default_Model_DbTable_Inclusion();
        $db_exclusion =  new Default_Model_DbTable_Exclusion();
        $db_cancellation = new Default_Model_DbTable_Cancellation();
        
        $tour = $db_tour->getTourId($tourId);
        if ($tour['inclusions']!=0)
        {
            $inclusion = $db_inclusion->getlistinclusion($tour['inclusions']);
        }
       	if ($tour['exclusions']!=0)
       	{
       	    $exclusion = $db_exclusion->getlistexclusion($tour['exclusions']);
       	}
       	if ($tour['cancellation']!=0)
       	{
       	    $cancellation = $db_cancellation->getlistcancellation($tour['cancellation']);
       	}
       	$similartour = $db_tour->getsimilartour($tour['cityId'], $tour['tourtypeId']);
    }
   
    
}